package com.after.saas.gateway.config;

import cn.hutool.core.util.StrUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.util.PatternMatchUtils;

import java.util.List;

/**
 * @Classname FreeAuthConfig
 * @Description TODO
 * @Date 2021/5/25 17:40
 * @Created by hjchen
 */

@Data
@Component
@ConfigurationProperties(prefix = "request-auth")
public class RequestListConfig {

    /**
     * 免菜单权限列表
     */
    private List<String> freeList;

    /**
     * 静态资源列表
     */
    private List<String> staticList;

    /**
     * 黑名单
     */
    private List<String> blackList;


    public boolean isMatched(List<String> source, String url) {
        return source.stream().filter(StrUtil::isNotBlank).anyMatch(x -> PatternMatchUtils.simpleMatch(x, url));
    }

}